﻿<%@ WebHandler Language="C#" Class="ClearCache" %>

using System;
using System.Web;

public class ClearCache : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {

        if (context.Request["key"] != null)
        {
            foreach (System.Collections.DictionaryEntry item in context.Cache)
            {
                if (item.Key.ToString().ToLower().Equals(context.Request["key"].ToString().ToLower()))
                    context.Cache.Remove(item.Key as string);
            }
        }
        else
        {
            foreach (System.Collections.DictionaryEntry item in context.Cache)
                context.Cache.Remove(item.Key as string);
        }
        context.Response.ContentType = "text/html";
        context.Response.Write("Cache cleared.");
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}